class AddressProvince{
 late int id;
 late String provinceid;
 late String province;
 late String lng;
 late String lat;
 late String name;
 late List<AddressCity> cities = [];

  AddressProvince(
      {required this.id,
        required this.provinceid,
        required this.province,
        required this.name,
        required this.lng,
        required this.lat,
        required this.cities});

  AddressProvince.fromJson(Map<String, dynamic> json, {required Map<String, AddressCity> cityMap, required Map<String, AddressDistrict> districtMap}) {
    id = json['id'];
    provinceid = json['provinceid'];
    province = json['province'];
    name = json['province'];
    lng = json['lng'];
    lat = json['lat'];
    if (json['cities'] != null) {
      json['cities'].forEach((v) {
        var city = AddressCity.fromJson(v, districtMap: districtMap);
        cityMap[city.cityid] = city;
        cities.add(city);
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['provinceid'] = provinceid;
    data['province'] = province;
    data['name'] = province;
    data['lng'] = lng;
    data['lat'] = lat;
    if (cities != null) {
      data['cities'] = cities.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class AddressCity {
  late int id;
  late String city;
  late String cityid;
  late String provinceid;
  late String name;
  late String lng;
  late String lat;
  late List<AddressDistrict> district = [];

  AddressCity(
      {required this.id,
        required this.city,
        required this.cityid,
        required this.provinceid,
        required this.name,
        required this.lng,
        required this.lat,
        required this.district});

  AddressCity.fromJson(Map<String, dynamic> json, {required Map<String, AddressDistrict> districtMap}) {
    id = json['id'];
    city = json['city'];
    cityid = json['cityid'];
    provinceid = json['provinceid'];
    name = json['city'];
    lng = json['lng'];
    lat = json['lat'];
    if (json['district'] != null) {
      json['district'].forEach((v) {
        var dis = AddressDistrict.fromJson(v);
        districtMap[dis.areaid] = dis;
        district.add(dis);
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['city'] = city;
    data['cityid'] = cityid;
    data['provinceid'] = provinceid;
    data['name'] = city;
    data['lng'] = lng;
    data['lat'] = lat;
    if (district != null) {
      data['district'] = district.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class AddressDistrict {
  late int id;
  late String area;
  late String areaid;
  late String cityid;
  late String name;
  late String lng;
  late String lat;

  AddressDistrict({
    required this.id,
    required this.area,
    required this.areaid,
    required this.cityid,
    required this.name,
    required this.lng,
    required this.lat});

  AddressDistrict.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    area = json['area'];
    areaid = json['areaid'];
    cityid = json['cityid'];
    name = json['area'];
    lng = json['lng'];
    lat = json['lat'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['area'] = area;
    data['areaid'] = areaid;
    data['cityid'] = cityid;
    data['name'] = area;
    data['lng'] = lng;
    data['lat'] = lat;
    return data;
  }
}

class AddressInternational{
  late String chineseName;
  late String country;
  late String region;
  late String shortName;
  late String showName;
  late String name;

  AddressInternational({
    required this.chineseName,
    required this.country,
    required this.region,
    required this.shortName,
    required this.showName,
    required this.name});

  AddressInternational.fromJson(Map<String, dynamic> json) {
    chineseName = json['chineseName'];
    country = json['country'];
    region = json['region'];
    shortName = json['shortName'];
    showName = json['showName'];
    name = json['chineseName'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['chineseName'] = chineseName;
    data['country'] = country;
    data['region'] = region;
    data['shortName'] = shortName;
    data['showName'] = showName;
    data['name'] = chineseName;
    return data;
  }
}
